package main

import (
	"sql/Common"
	"fmt"
)

func GetInsertSql() {
	sqlMaker := Common.NewSqlMaker()
	sqlMaker.SetTable("test")
	sqlMaker.Set("id", "1")
	sqlMaker.Set("name", "zhouchun")
	sql, placeholder := sqlMaker.GetInsertSql()
	fmt.Println(sql)
	fmt.Println(placeholder)
	fmt.Println("-----")
}

func GetUpdateSql() {
	sqlMaker := Common.NewSqlMaker()
	sqlMaker.SetTable("test")
	sqlMaker.Set("id", "1")
	sqlMaker.Set("name", "zhouchun")
	sqlMaker.Where("age", "<=", "30")
	sqlMaker.AndWhere("sex", "=", "1")
	sql, placeholder := sqlMaker.GetUpdateSql()
	fmt.Println(sql)
	fmt.Println(placeholder)
	fmt.Println("-----")
}

func GetDeleteSql() {
	sqlMaker := Common.NewSqlMaker()
	sqlMaker.SetTable("test")
	sqlMaker.Where("id", "in", "1,2")
	sql, placeholder := sqlMaker.GetDeleteSql()
	fmt.Println(sql)
	fmt.Println(placeholder)
	fmt.Println("-----")
}

func GetSelectSql() {
	sqlMaker := Common.NewSqlMaker()
	sqlMaker.SetField("id")
	sqlMaker.SetField("name")
	sqlMaker.SetTable("test")
	sqlMaker.Where("age", "<=", "30")
	sqlMaker.AndWhere("sex", "=", "1")
	sql, placeholder := sqlMaker.GetSelectSql()
	fmt.Println(sql)
	fmt.Println(placeholder)
	fmt.Println("-----")
}

func main() {
	GetInsertSql()
	GetUpdateSql()
	GetDeleteSql()
	GetSelectSql()
}